/**
 * 开庭统计js
 */

var startTime = utils.get_url_param("startTime");
var endTime = utils.get_url_param("endTime");

var temp = new Date();
var defaultStartTime = temp.getFullYear() + "-01-01";
var height = $(document).height();
var typeNames = ["刑事", "民事", "行政", "赔偿", "执行", "信访", "其他"];
var casetype = utils.get_url_param("casetype");
var sortdatas = null;  //保存table的数据用作排序
var allCaseType = null; //保存案件类型的key-value
$(function () {
    $('#startTime').datetimepicker({
        bootcssVer: 3,
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        weekStart: "1",
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    }).on('changeDate', function (ev) {
        console.log(ev.date.valueOf());
    });
    $('#endTime').datetimepicker({
        bootcssVer: 3,
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        weekStart: "1",
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    }).on('changeDate', function (ev) {
        console.log(ev.date.valueOf());
    });
    if (null == endTime) {
        $("#endTime").find("input").val(utils.get_date(0));
    } else {
        $("#endTime").find("input").val(endTime);
    }

    if (null == startTime) {
        $("#startTime").find("input").val(defaultStartTime);
    } else {
        $("#startTime").find("input").val(startTime);
    }

    $("#_search").click(function () {
        init();
    });
    selectAllCaseType();
    init();
    casetype = null;
    $(".container-fluid").show();
});

function init() {
    $("#loading").show();
    if (r.flag_search) {
        getAllOpenCountDataByBar();
    } else {
        getOpenCountDataByBar();
    }
}

function selectAllCaseType() {
    var temp = casetype;
    $.ajax({
        type: "get",
        url: r.base_path + "caseCount/getAllCaseType",
        async: false,
        datatype: "json",
        success: function (result) {
//    		var result = eval('(' + result + ')'); 
            console.info(result);
            if (result.data) {
                allCaseType = result.data;
                $("#caseType").empty();
                $("#caseType").append("<option value=''>" + "所有类型" + "</option>");
                $.each(result.data, function (i, valueOfElement) {
                    $("#caseType").append("<option value='" + valueOfElement.uid + "'>" + valueOfElement.name + "</option>");
                });
                console.log(temp, $("#caseType").html());
                $("#caseType").val(temp);
            }
        }
    });
}

function getOpenCountDataByBar() {
    var caseTypeName = casetype ? casetype : $("#caseType").val();
    var start = $("#startTime").find("input").val();
    var end = $("#endTime").find("input").val();
    $.post(r.base_path + "caseCount/getCaseCount", {
        courtUid: r.court_uid,
        startDate: start,
        endDate: end,
        caseType: caseTypeName,
        status: 0
    }, function (result) {
        result = result.data;
        var courtroomNames = [];
        var datas = [];
        $(result).each(function (index, elem) {
            courtroomNames.indexOf(elem.courtroomName) != -1 ? "" : courtroomNames.push(elem.courtroomName);
            //typeNames.indexOf(elem.typename)!=-1?"":typeNames.push(elem.typename);
        });

        $(courtroomNames).each(function (index, ele) {
            var temp = {};
            var total = 0;
            temp["courtroomName"] = ele;
            $(typeNames).each(function (index, elem) {
                temp[elem] = 0;
            });
            $(result).each(function (index, elem) {
                if (ele == elem.courtroomName) {
                    temp["courtroomUid"] = elem.courtroomUid;
                    $(elem.data).each(function (index, eleme) {
                        total = total + eleme.count;
                        if ("未知" == eleme.typeName) {
                            temp["其他"] = temp["其他"] + eleme.count;
                        } else {
                            temp[eleme.typeName] = temp[eleme.typeName] + eleme.count;
                        }
                    });
                }
            });
            temp["total"] = total;
            datas.push(temp);
        });
        datas.sort(function compare(a, b) {
            return b.total - a.total;
        });
        console.info(datas);
        var xAxis = [];
        var yAxis = [];
        $(datas).each(function (index, elem) {
            xAxis.push(elem.courtroomName);
            yAxis.push(elem.total);
        });
        sortdatas = datas;
        initHistogramEchart(xAxis, yAxis);
        loadTableCharts(datas);
        $("#loading").hide();
    }, 'json');
}
function getAllOpenCountDataByBar() {
    var caseTypeName = casetype ? casetype : $("#caseType").val();
    var start = $("#startTime").find("input").val();
    var end = $("#endTime").find("input").val();
    $.post(r.base_path + "caseCount/getCaseCount", {
        courtUid: r.court_uid,
        startDate: start,
        endDate: end,
        caseType: caseTypeName,
        status: 1
    }, function (result) {
        result = result.data;
        var courtUids = [];
        var datas = [];
        $(result).each(function (index, elem) {
            courtUids.indexOf(elem.courtUid) != -1 ? "" : courtUids.push(elem.courtUid);
        });

        $(courtUids).each(function (index, ele) {
            var temp = {};
            var total = 0;
            temp["courtUid"] = ele;
            $(typeNames).each(function (index, elem) {
                temp[elem] = 0;
            });
            $(result).each(function (index, elem) {
                if (ele == elem.courtUid) {
                    temp["courtName"] = elem.courtName;
                    temp["length"] = elem.length;
                    $(elem.data).each(function (index, eleme) {
                        total = total + eleme.count;
                        if ("未知" == eleme.typeName) {
                            temp["其他"] = temp["其他"] + eleme.count;
                        } else {
                            temp[eleme.typeName] = temp[eleme.typeName] + eleme.count;
                        }
                    });
                }
            });
            temp["total"] = total;
            datas.push(temp);
        });
        datas.sort(function compare(a, b) {
            return b.total - a.total;
        });
        var xAxis = [];
        var yAxis = [];
        $(datas).each(function (index, elem) {
            xAxis.push(elem.courtName);
            yAxis.push(elem.total);
        });
        sortdatas = datas;
        console.info(datas);
        initHistogramEchart(xAxis, yAxis);
        allLoadTableCharts(datas);
        $("#loading").hide();
    }, 'json');
}

/*function loadTableCharts(result){
 var start = $("#startTime").find("input").val();
 var end = $("#endTime").find("input").val();
 $("#table").find("thead").html("");
 $("#table").find("thead").append('<tr><td>序号</td><td>法院</td><td>开庭次数</td></tr>');
 $(result).each(function (index, elem) {
 $("#table").find("tbody").append('<tr><td>' +(index+1) + '</td><td onclick="gotoCaseType(\"'+elem.id+'\",\"'+start+'\",\"'+end+'\")" >' + elem.courtname + '</td><td>' + elem.total + '</td></tr>');
 });
 }*/

function loadTableCharts(result) {
    var start = $("#startTime").find("input").val();
    var end = $("#endTime").find("input").val();
    var caseType = $("#caseType").val();
    $('#table').bootstrapTable({
        columns: [{
            field: 'Number',
            title: '序号',
            class: 'table-num',
            formatter: function (value, row, index) {
                return (index + 1) > 9 ? index + 1 : '0' + (index + 1);
            },
            footerFormatter: "总计"
        }, {
            field: 'courtroomName',
            width: '15%',
            class: 'table_courtroom_name',
            title: '法庭'
        }, {
            field: '刑事',
            class: 'a1',
            title: '刑事',
            sortable: true,
            footerFormatter: function (result) {
                var total = 0;
                $(result).each(function (index, ele) {
                    total = total + ele.刑事;
                });
                if (0 == total) {
                    return "0";
                }
                return total;
            }
        },
            {
                field: '民事',
                class: 'a2',
                title: '民事',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.民事;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '行政',
                class: 'a5',
                title: '行政',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.行政;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '赔偿',
                class: 'a4',
                title: '赔偿',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.赔偿;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '执行',
                class: 'a3',
                title: '执行',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.执行;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '信访',
                class: 'a6',
                title: '信访',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.信访;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '其他',
                class: 'a7',
                title: '其他',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.其他;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: 'total',
                class: 'null',
                title: '开庭总数',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.total;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                },
                sorter: function (a, b) {
                    return a - b;
                }
            }, {
                field: 'courtroomId',
                class: 'hidden',
                title: '法庭id'
            }],
        data: result,
        showFooter: true,
        sortName: 'total',
        sortOrder: 'desc',
        sortStable: true
    });
    $('#table').bootstrapTable("load", result);
    $('#table').bootstrapTable("hideColumn", "courtname");
    $('#table').bootstrapTable("showColumn", "courtroomNname");

    var caseTypeValue = $("#caseType").val();
    var caseTypeName = null;
    $(allCaseType).each(function (index, elem) {
        if (elem.uid == caseTypeValue) {
            caseTypeName = elem.name;
        }
    });

    if (caseTypeName) {
        var typeNamesTable = [caseTypeName];
    } else {
        var typeNamesTable = ["刑事", "民事", "行政", "赔偿", "执行", "信访", "其他"];
    }

    $(typeNames).each(function (index, elem) {
        if (typeNamesTable.indexOf(elem) == -1) {
            $('#table').bootstrapTable("hideColumn", elem);
        } else {
            $('#table').bootstrapTable("showColumn", elem);
        }
    });


    //必须放在判断显示几列后面，否则不生效
    $('.fixed-table-footer').find('table').find('tbody').find('td').click(function () {
        var clickIndex = $(this).index();
        var clickType = $(this).attr('class');
        if (!clickType || 'null' == clickType) {
            clickType = $("#caseType").val();
        }
//    	console.log(clickIndex,clickType);
        //获取当前的时间
        var start = $("#startTime").find("input").val();
        var end = $("#endTime").find("input").val();
        if (clickIndex > 1) {
            window.location.href = r.base_path + 'more/more_review?currentCourtUid=' + r.court_uid + '&caseType=' + clickType + '&start=' + start + '&end=' + end + "&_search=false";
        }
    });

}

function clickCell(cell) {
    var src = cell.srcElement || cell.target;
    src = $(src);
    //获取点击的列数
    var index = src.index();
    //获取点击的案件类型clickCaseType
    var type = $('#table').find('thead').find('tr:eq(0)').find("th:eq(" + index + ")").attr("class");
    if (!type || 'null' == type) {
        type = $("#caseType").val();
    }
//	var clickCaseType = null;
//	$(allCaseType).each(function (index, elem) {
//		if(elem.name == type){
//			clickCaseType = elem.uid;
//		}
//	});

//	var caseTypeName = $("#caseType").val();
//	if(!caseTypeName){
//		caseTypeName = clickCaseType;
//	}
    //获取当前的时间
    var start = $("#startTime").find("input").val();
    var end = $("#endTime").find("input").val();

    if (r.flag_search) {
        //length为点击法院的子法院个数
        var length = src.parent().find("td:last").html();
        var lastIndex = src.parent().find("td:last").index();
        //clickCourtId为点击法院id
        var clickCourtId = src.parent().find("td:eq(" + (lastIndex - 1) + ")").html();
//		console.info(index,type,clickCaseType,length,clickCourtId);

        if (index == 1) {
            type = $("#caseType").val();
            window.location.href = r.base_path + 'case_count/open_court_number_count?caseType=' + type + '&startTime=' + start + '&endTime=' + end + '&courtUid=' + clickCourtId;
        } else if (index > 1) {
            if (clickCourtId == r.court_uid) {

                window.location.href = r.base_path + 'more/more_review?currentCourtUid=' + clickCourtId + '&caseType=' + type + '&start=' + start + '&end=' + end + "&_search=false";
            } else {

                window.location.href = r.base_path + 'more/more_review?currentCourtUid=' + clickCourtId + '&caseType=' + type + '&start=' + start + '&end=' + end + "&_search=true";
            }
        }
    } else {
        //clickCourtroomId为点击的法庭id
        var clickCourtroomId = src.parent().find("td:last").html();
//		console.info(index,type,clickDeptId);
        if (index > 1) {
            window.location.href = r.base_path + 'more/more_review?currentCourtUid=' + r.court_uid + '&caseType=' + type + '&start=' + start + '&end=' + end + "&_search=false";
        }

    }
}

/*function loadTableCharts(result){
 //	alert(sortindex);
 var caseTypeName = $("#caseType").val();

 $(allCaseType).each(function (index, elem) {
 if(elem.uid == caseTypeName){
 caseTypeName = elem.name;
 }
 });

 if(caseTypeName){
 typeNamesTable = [caseTypeName];
 }else{
 typeNamesTable = ["刑事","民事","行政","赔偿","执行","信访","其他"];
 }

 var thead =  '<tr><td>序号</td><td>部门</td>';
 $(typeNamesTable).each(function (index, elem){
 thead = thead + '<td onclick="dosort(\''+elem+'\')" >'+elem+'</td>';
 });
 thead = thead + '<td onclick="dosort(\'total\')" >开庭总数</td><td hidden="hidden">部门id</td></tr>';
 $("#table").find("thead").empty();
 $("#table").find("thead").append(thead);

 $("#table").find("tbody").empty();
 var tempfeet = {};
 $(typeNamesTable).each(function (index1, elem1){
 tempfeet[elem1] = 0;
 });

 $(result).each(function (index, elem) {
 var tr = '<tr><td>' +(index+1) + '</td><td>' + elem.deptname + '</td>';
 $(typeNamesTable).each(function (index1, elem1){
 tr = tr + '<td>'+elem[elem1]+'</td>';
 tempfeet[elem1] = tempfeet[elem1] + elem[elem1];
 });
 tr = tr + '<td>'+elem.total+'</td>'+'<td hidden="hidden">'+elem.deptId+'</td>'+'</tr>';
 $("#table").find("tbody").append(tr);
 });
 var temptotal = 0;
 var feet = '<tr><td>总计</td><td></td>';
 $(typeNamesTable).each(function (index1, elem1){
 feet = feet + '<td>'+tempfeet[elem1]+'</td>';
 temptotal = temptotal + tempfeet[elem1];
 });
 feet = feet + '<td>'+temptotal+'</td><td hidden="hidden"></td></tr>';
 $("#table").find("tbody").append(feet);
 }*/

/*function allLoadTableCharts1(result){
 var caseTypeName = $("#caseType").val();

 $(allCaseType).each(function (index, elem) {
 if(elem.uid == caseTypeName){
 caseTypeName = elem.name;
 }
 });

 if(caseTypeName){
 typeNamesTable = [caseTypeName];
 }else{
 typeNamesTable = ["刑事","民事","执行","赔偿","行政","信访","其它"];
 }



 var thead =  '<tr><td>序号</td><td>法院</td>';
 $(typeNamesTable).each(function (index, elem){
 thead = thead + '<td onclick="dosort(\''+elem+'\')" >'+elem+'</td>';
 });
 thead = thead + '<td onclick="dosort(\'total\')" >开庭总数</td><td hidden="hidden">法院id</td><td hidden="hidden">子法院数</td></tr>';
 $("#table").find("thead").empty();
 $("#table").find("thead").append(thead);

 $("#table").find("tbody").empty();
 var tempfeet = {};
 $(typeNamesTable).each(function (index1, elem1){
 tempfeet[elem1] = 0;
 });

 $(result).each(function (index, elem) {
 var tr = '<tr><td>' +(index+1) + '</td><td>' + elem.courtname + '</td>';
 $(typeNamesTable).each(function (index1, elem1){
 tr = tr + '<td>'+elem[elem1]+'</td>';
 tempfeet[elem1] = tempfeet[elem1] + elem[elem1];
 });
 tr = tr + '<td>'+elem.total+'</td>'+'<td hidden="hidden">'+elem.id+'</td>'+'<td hidden="hidden">'+elem.length+'</td>'+'</tr>';
 $("#table").find("tbody").append(tr);
 });
 var temptotal = 0;
 var feet = '<tr><td>总计</td><td></td>';
 $(typeNamesTable).each(function (index1, elem1){
 feet = feet + '<td>'+tempfeet[elem1]+'</td>';
 temptotal = temptotal + tempfeet[elem1];
 });
 feet = feet + '<td>'+temptotal+'</td><td hidden="hidden" >'+courtId+'</td><td hidden="hidden"></td></tr>';
 $("#table").find("tbody").append(feet);
 }
 */

/*var sortindex = 0;

 function dosort(value){
 console.info(sortdatas);
 if(sortindex == 0){
 sortdatas.sort(function compare(a,b){return b[value]-a[value];});
 sortindex = 1;
 }else{
 sortdatas.sort(function compare(a,b){return a[value]-b[value];});
 sortindex = 0;
 }
 if(search){
 allLoadTableCharts(sortdatas);
 }else{
 loadTableCharts(sortdatas);
 }

 }*/

function allLoadTableCharts(result) {
    console.info(result);
    $('#table').bootstrapTable({
        columns: [{
            field: 'Number',
            title: '序号',
            footerFormatter: "总计",
            class: 'table-num',
            formatter: function (value, row, index) {
                return (index + 1) > 9 ? index + 1 : '0' + (index + 1);
            }
        }, {
            field: 'courtName',
            title: '法院'
        }, {
            field: '刑事',
            class: 'a1',
            title: '刑事',
            sortable: true,
            footerFormatter: function (result) {
                var total = 0;
                $(result).each(function (index, ele) {
                    total = total + ele.刑事;
                });
                if (0 == total) {
                    return "0";
                }
                return total;
            }
        },
            {
                field: '民事',
                class: 'a2',
                title: '民事',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.民事;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '行政',
                class: 'a5',
                title: '行政',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.行政;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '赔偿',
                class: 'a4',
                title: '赔偿',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.赔偿;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '执行',
                class: 'a3',
                title: '执行',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.执行;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '信访',
                class: 'a6',
                title: '信访',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.信访;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: '其他',
                class: 'a7',
                title: '其他',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.其他;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                }
            },
            {
                field: 'total',
                class: 'null',
                title: '开庭总数',
                sortable: true,
                footerFormatter: function (result) {
                    var total = 0;
                    $(result).each(function (index, ele) {
                        total = total + ele.total;
                    });
                    if (0 == total) {
                        return "0";
                    }
                    return total;
                },
                sorter: function (a, b) {
                    return a - b;
                }
            }, {
                field: 'courtUid',
                class: 'hidden',
                title: '法院id'
            }, {
                field: 'length',
                class: 'hidden',
                title: '子法院数'
            }],
        data: result,
        showFooter: true,
        sortName: 'total',
        sortOrder: 'desc',
        sortStable: true
//		onClickRow:function (row) {
//            var start = $("#startTime").find("input").val();
//            var end = $("#endTime").find("input").val();
//            var caseType = $("#caseType").val();
//			if(row.id){
//				if(row.id==courtId){
//					// setCookie("_search",0 );
//					window.location.href='more_reviewing.html?currentCourtid='+row.id+'&caseType='+caseType+'&start='+start+'&end='+end+ "&court=" + row.id+ "&_search=false";
//				}else if(row.length==0){
//					// setCookie("_search",0 );
//					 window.location.href='more_reviewing.html?currentCourtid='+row.id+'&caseType='+caseType+'&start='+start+'&end='+end+ "&court=" + row.id+ "&_search=false";
//				}else{
//					window.location.href='open_court_number_count.html?caseType='+caseType+'&startTime='+start+'&endTime='+end+'&court='+row.id;
//					//_initNavbar(row.id);
//				}
//			}
//		}
    });
    $('#table').bootstrapTable("load", result);
    $('#table').bootstrapTable("hideColumn", "deptname");
    $('#table').bootstrapTable("showColumn", "courtname");

    var caseTypeValue = $("#caseType").val();
    var caseTypeName = null;
    $(allCaseType).each(function (index, elem) {
        if (elem.uid == caseTypeValue) {
            caseTypeName = elem.name;
        }
    });

    if (caseTypeName) {
        var typeNamesTable = [caseTypeName];
    } else {
        var typeNamesTable = ["刑事", "民事", "行政", "赔偿", "执行", "信访", "其他"];
    }

    $(typeNames).each(function (index, elem) {
        if (typeNamesTable.indexOf(elem) == -1) {
            $('#table').bootstrapTable("hideColumn", elem);
        } else {
            $('#table').bootstrapTable("showColumn", elem);
        }
    });

    $('.fixed-table-footer').find('table').find('tbody').find('tr').find('td').click(function () {
        var clickIndex = $(this).index();
        var clickType = $(this).attr('class');
        if (!clickType || 'null' == clickType) {
            clickType = $("#caseType").val();
        }
//    	console.log(clickIndex,clickType);
        //获取当前的时间
        var start = $("#startTime").find("input").val();
        var end = $("#endTime").find("input").val();
        if (clickIndex > 1) {
            window.location.href = r.base_path + 'more/more_review?currentCourtUid=' + r.court_uid + '&caseType=' + clickType + '&start=' + start + '&end=' + end + "&_search=true";
        }
    });
}

/**
 * 柱状图
 * @param xdata
 * @param ydata
 * @param title
 */
function initHistogramEchart(xdata, ydata, title) {
    $("#loading").hide();
    $("#pic").show();
    // console.log(xdata,ydata);
    // 基于准备好的dom，初始化echarts实例
    // var width = $(document.body).width();
    // $("#canvas").css("width", width * 0.63);
    console.log($("#canvas"), $("#canvas").width(), $("#canvas").height());
    var myChart = echarts.init(document.getElementById('canvas'), "shine");
    // 指定图表的配置项和数据
    var option = {
        title: {
            text: "开庭数统计(次)", //正标题
            x: "left", //标题水平方向位置
            textStyle: {
                fontSize: 24,
                color: "#FFFFFF"
            }
        },
        color: ['#D5B136'],
        /* title:{
         text:title,
         textStyle:{
         color:"#ffffff"
         }
         },*/
        grid: {
            left: '6%',
            right: '3%'
            // bottom: '20%',
            // containLabel: true
        },
        tooltip: {},
        xAxis: {
            data: xdata,
            axisLine: {
                lineStyle: {
                    color: "#1c4e93"
                }
            },
            axisLabel: {
                textStyle: {
                    fontSize: 16,
                    color: "#FFFFFF"
                },
                // rotate:-30,
                interval: 0
            }
        },
        yAxis: {
            axisLine: {
                lineStyle: {
                    color: "#1c4e93"
                }
            },
            axisLabel: {
                textStyle: {
                    fontSize: 16,
                    color: "#FFFFFF"
                },
                formatter: function (value) {
                    return value + '次'
                }
            }
        },
        series: [{
            name: '开庭数',
//            barWidth: '50%',
            barMaxWidth: 20,
            type: 'bar',
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        position: 'top',
                        textStyle: {
                            color: "#d94600",
                            fontSize: 20
                        }
                    }
                }
            },
            data: ydata
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    window.onresize = myChart.resize;
}


